V2EX  ›  英汉词典

Type Promotion

释义 Definition

type promotion 指在编程语言中,较小或较“窄”的数据类型在表达式计算时被自动提升为较大或较“宽”的类型,以便进行运算或匹配函数参数(常见于 C/C++ 等语言)。例如 charshort 在算术运算中常会先提升为 int。在不同语言里也可能与“隐式类型转换(implicit conversion)”相关,但侧重点在“提升到更高精度/更大范围”。

发音 Pronunciation (IPA)

/taɪp prəˈməʊʃən/

例句 Examples

Type promotion can change the result of an arithmetic expression.
类型提升可能会改变算术表达式的计算结果。

In C, integer promotions may convert a char to an int before evaluation, which helps avoid overflow in some cases but can also introduce subtle bugs.
在 C 语言中,整数提升可能会在求值前把 char 转成 int,这在某些情况下有助于避免溢出,但也可能引入细微的 bug。

词源 Etymology

type 源自希腊语 typos(印记、模型、类型),经拉丁语与法语进入英语;promotion 来自拉丁语 promovere(向前推进、提升)。组合在编程语境中表示“把类型向更高层级/更大表示范围推进”的过程。

相关词 Related Words

文学与著作 Literary Works

  • The C Programming Language(Kernighan & Ritchie,常涉及“integer promotions/类型提升”等规则)
  • C: A Reference Manual(Harbison & Steele,对 C 的提升与转换规则有系统说明)
  • The C++ Programming Language(Bjarne Stroustrup,讨论 C++ 的隐式转换与提升机制)
  • *ISO/IEC 9899 (C Standard)*(C 语言标准文本中明确规定 integer promotions 与 usual arithmetic conversions)
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1442 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 16:16 · PVG 00:16 · LAX 08:16 · JFK 11:16
♥ Do have faith in what you're doing.